<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="物料编码" prop="itemCode">
        <el-input v-model="queryParams.itemCode" placeholder="请输入物料编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="物料名称" prop="itemName">
        <el-input v-model="queryParams.itemName" placeholder="请输入物料名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['mes:prod:workHour:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="mdItemList">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" label="序号" align="center" width="50" />
      <el-table-column label="物料编码" align="center" prop="itemCode" />
      <el-table-column label="物料名称" align="center" prop="itemName" />
      <el-table-column label="修改前标准工时" align="center" prop="beforePerUnitStandHour" />
      <el-table-column label="修改后标准工时" align="center" prop="perUnitStandHour" />
      <el-table-column label="操作人" align="center" prop="createBy" />
      <el-table-column label="操作时间" align="center" prop="createTime" />

      <!-- 规格型号  specification
     单位 measureName
     所属分类 categoryName
     是否启用.N=否,Y=是  enableFlag
     单位 unitOfMeasure
产品物料标识 itemOrProduct
物料类型ID  itemTypeId
物料类型编码 itemTypeCode
物料类型名称 itemTypeName
标志 safeStockFlag
最小库存 minStock
最大库存 maxStock
金蝶云编码 jdyItemId
安全库存 safeStock
      物料列表 mdItemLogIdList
      来料检 checkIncoming
      质检方案行表id  schemeId
    质检方案是否选择了该物料 isChoose
    标准工时 fTbibAttachment
    totalHours -->

    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>

<script>
import {
  mdItemLogList,
} from "@/api/mes/pro/mdItemLog";
import moment from "moment";
export default {
  name: "MdItemLog",
  data() {
    return {
      //自动生成编码
      autoGenFlag: false,
      optType: undefined,

      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 生产工序表格数据
      mdItemList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      mdItemLogList(this.queryParams).then(response => {
        this.mdItemList = response.rows;
        this.total = response.total;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.autoGenFlag = false;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "mes/md/mditemlog/export",
        {
          ...this.queryParams
        },
        `产品工时更改记录_${moment(new Date()).format('yyyyMMDDHHmmss')}.xlsx`
      );
    },
  }
};
</script>
